home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Garbo
/
Garbo.cdr
/
mac
/
unix
/
textmstr.shr
/
tm.hqx
/
Source Code ƒ
/
TextMaster Code
/
tm.c
< prev
next >
Wrap
Text File
|
1991-05-09
|
2KB
|
63 lines
/*************************************************************************
** **
** TM **
** TextMaster 1.4 **
** **
** By Donald Burr -- Copyright 1991 **
** **
** Released to the Public Domain **
** **
** Version History **
** **
** Date Version Comments **
** ---- ------- -------- **
** 15-Mar-91 1.0 Initial release. **
** Fixed file closure bug; it now properly **
** closes files when done with them. **
** **
** 09-May-91 1.4 Standardized the version number with the **
** UNIX Version. Fixed problem where it **
** couldn't convert Mac -> UNIX. **
** **
*************************************************************************/
#include <stdio.h> /* Standard I/O functions */
#include <string.h> /* BSD uses strings.h */
#include "tm.h" /* defines for TextMaster */
void tm(thing_to_do, in, out) /* main TextMaster function */
int thing_to_do; /* what to do, what to do */
char *in, *out;
{
char the_input, the_output; /* input gathered from program */
char do_the_conversion(); /* this function does the stuff */
FILE *infile, *outfile, *fopen();
int fclose();
/* Assign filenames */
infile = fopen(in, "r"); /* open the file specified --
binary mode to insure correct
read of certain chars */
if (thing_to_do == MAC_TO_UNIX)
outfile = fopen(out, "wb"); /* to xfer to UNIX, must write
binary file, or else it gets
dumb and writes Mac EOLs */
else /* thing_to_do == UNIX_TO_MAC) */
outfile = fopen(out, "w");
/* Get input char-by-char */
while ((the_input = fgetc(infile)) != EOF) {
/* while we've still got stuff */
the_output = do_the_conversion(the_input, thing_to_do);
fputc(the_output, outfile);
/* Do the conversion */
}
putchar(BELL); /* Beep to let know of completion */
printf("\nTextMaster is complete. %s has been converted to %s.\n",
in, out);
fclose(infile);
fclose(outfile);
}